package com.tulele.vtool.wechat.service;

import com.google.common.collect.Maps;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Map;

public class WeixinServiceMap {

    static Map<String, WeixinServiceDL> wsMap = Maps.newHashMapWithExpectedSize(10);

    public synchronized static void putWeixinService(String gzhCode, WeixinServiceDL weixinService) { //添加同步块
        if(!wsMap.containsKey(gzhCode)){
            wsMap.put(gzhCode,weixinService);
        }
    }

    public static WeixinServiceDL getWeixinService(String gzhCode) {
        WeixinServiceDL weixinService=null;
        if(wsMap.containsKey(gzhCode)){
            weixinService=wsMap.get(gzhCode);
        }
        return weixinService;
    }

    public static Map<String, WeixinServiceDL> getWeixinServiceMap() {
        return wsMap;
    }

    public static void removeWeixinService(String gzhCode) {
        if(wsMap.containsKey(gzhCode)){
            wsMap.remove(gzhCode);
        }
    }

}
